package xps.and.uudaijia.userclient.view.activity;

import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMWeb;
import com.zhy.autolayout.AutoLinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import xps.and.uudaijia.userclient.R;
import xps.and.uudaijia.userclient.view.base.BaseActivity;

/**
 * Created by Administrator on 2017/6/29.
 */

public class InvitationActivity extends BaseActivity implements UMShareListener {
    @BindView(R.id.al_share_qq)
    AutoLinearLayout alShareQq;
    @BindView(R.id.al_share_qzone)
    AutoLinearLayout alShareqzone;
    @BindView(R.id.al_share_wx_circle)
    AutoLinearLayout alShareWxCircle;
    @BindView(R.id.al_share_wx)
    AutoLinearLayout alShareWx;
    @BindView(R.id.al_share_sms)
    AutoLinearLayout alShareSms;
    @BindView(R.id.actionbar_iv_back)
    ImageView actionbarIvBack;

    @Override
    protected int getLayout() {
        return R.layout.activity_invitation;
    }

    @Override
    protected void setData() {

    }

    @Override
    protected void init() {
        ButterKnife.bind(this);
    }

    @OnClick({R.id.actionbar_iv_back, R.id.al_share_qq, R.id.al_share_qzone, R.id.al_share_wx_circle, R.id.al_share_wx, R.id.al_share_sms})
    public void onViewClicked(View view) {
        UMWeb webWX = new UMWeb("http://www.xn--uu-df3cl18z.com/");
        webWX.setTitle("UU智行");//标题
        webWX.setDescription("找代驾？快来加入UU智行吧！");//描述
        switch (view.getId()) {
            case R.id.al_share_qq:
                new ShareAction(this).setPlatform(SHARE_MEDIA.QQ)
                        .withText("hello")
                        .withMedia(webWX)
                        .setCallback(this)
                        .share();
                break;
            case R.id.al_share_qzone:
                new ShareAction(this).setPlatform(SHARE_MEDIA.QZONE)
                        .withText("hello")
                        .withMedia(webWX)
                        .setCallback(this)
                        .share();
                break;
            case R.id.al_share_wx_circle:

                UMWeb webWXC = new UMWeb("http://www.xn--uu-df3cl18z.com/");
                webWXC.setTitle("UU智行");//标题
                webWXC.setDescription("找代驾？快来加入UU智行吧！");//描述
                new ShareAction(this).setPlatform(SHARE_MEDIA.WEIXIN_CIRCLE)
                        .withText("hello")
                        .withMedia(webWXC)
                        .setCallback(this)
                        .share();
                break;
            case R.id.al_share_wx:
                UMWeb webWXC1 = new UMWeb("http://www.xn--uu-df3cl18z.com/");
                webWXC1.setTitle("UU智行");//标题
                webWXC1.setDescription("找代驾？快来加入UU智行吧！");//描述
                new ShareAction(this).setPlatform(SHARE_MEDIA.WEIXIN)
                        .withText("hello")
                        .withMedia(webWXC1)
                        .setCallback(this)
                        .share();
                break;
            case R.id.al_share_sms:
                new ShareAction(this).setPlatform(SHARE_MEDIA.SMS)
                        .withText("hello")
                        .setCallback(this)
                        .share();
                break;
            case R.id.actionbar_iv_back:
                finish();
                break;
        }
    }

    @Override
    public void onStart(SHARE_MEDIA share_media) {

    }

    @Override
    public void onResult(SHARE_MEDIA platform) {
        if (platform.name().equals("WEIXIN_FAVORITE")) {
            Toast.makeText(InvitationActivity.this, "收藏成功啦", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(InvitationActivity.this, "分享成功啦", Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public void onError(SHARE_MEDIA share_media, Throwable throwable) {
        Toast.makeText(InvitationActivity.this, " 分享失败", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onCancel(SHARE_MEDIA share_media) {
        Toast.makeText(InvitationActivity.this, " 已取消分享", Toast.LENGTH_SHORT).show();
    }

}
